package com.tank.fire;


import com.net.Client;
import com.net.entity.BulletNewMessage;
import com.tank.entrity.Bullet;
import com.tank.entrity.Tank;
import com.tank.model.GameModel;
import static com.tank.entrity.Tank.BARREL;

public class DefaultFireStrategy implements FireStrategy{

    @Override
    public void fire(Tank tank) {
        try {
            BARREL.acquire();
            Bullet bullet = new Bullet(tank.getUuid(), (int)tank.getX() + (tank.getWidth() / 2), (int)tank.getY(), tank.getDirectionEnum(),tank.getGroupType());
            GameModel.getInstance().addObject(bullet);
            Client.INSTANCE.send(new BulletNewMessage(bullet));
        } catch (Exception e) {
            e.getLocalizedMessage();
        }
    }
}
